﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<style type="text/css">
    .ui-jqgrid .table-bordered th { height: 52px !important; }
</style>
<script type="text/javascript">
    $(function () {
        initControl();
        gridList();
    });
    function initControl() {
        $('select').bindSelect();
    }
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/BOM/Product/GetStampingListByOrderJson",
            height: $(window).height() - 134,
            colModel: [
                { label: '零件编号', name: 'FProductionNO', width: 120, align: 'left', sortable: false, frozen: true },
                { label: '零件名称', name: 'MC', width: 240, align: 'left', sortable: false, frozen: true },
                { label: '装配<br />路线', name: 'AssembleLine', width: 40, align: 'left', sortable: false },
                { label: '制造路线', name: 'MakeLine', width: 180, align: 'left', sortable: false },
                {
                    label: '车型', name: '', width: 150, align: 'right', sortable: false, formatter: function(cellvalue, options, rowObject) {
                        return rowObject[$('#FOrderNum').val()];
                    }
                },
                { label: '备注', name: '备注', width: 10, align: 'center', sortable: false },
                @*@foreach (var item in ViewBag.orderList) { 
                    @Html.Raw("{ label: '" + @item.ProductNO2 + "', name: 'SL" + @item.OrderNum.ToString("000") + "', width: 70, align: 'right', sortable: false, formatter: function (cellvalue) { return cellvalue > 0 ? cellvalue : '';} },");
                    if (ViewBag.orderList.Count <= 7) { 
                        @Html.Raw("{ label: '备注', name: '', width: 10, align: 'center', sortable: false }");
                    }
                }*@
            ],
            pager: "#gridPager",
            sortname: 'FProductionNO asc',
            viewrecords: true,
            rownumWidth: 40
        });
        $gridList.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        $gridList.jqGrid('setFrozenColumns');
        $("#btn_search").click(function () {
            var FOrderNum = "车型";
            if ($('#FOrderNum').val() != '') {
                FOrderNum = $('#FOrderNum option:selected').text();
            }
            $gridList.jqGrid('setLabel', 5, FOrderNum, 'rowNumberHeaderStyle');
            $gridList.jqGrid('setGridParam', {
                postData: { number: $("#txtNumber").val(), name: $("#txtName").val(), assemble: $("#txtAssemble").val(), make: $("#txtMake").val(), orderNum: $('#FOrderNum').val() },
            }).trigger('reloadGrid');
        });
    }
</script>
<div id="layout" style="height: 100%; width: 100%;">
    <form id="form1">
        <div style="padding: 12px 0 5px 0; padding-left: 15px; border-bottom: 1px solid #ccc; " class="line-table input-width-105">
            <div class="btn-group input-width-185" style="margin-top:-9px;">
                车型编号<br />
                <select id="FOrderNum" name="FOrderNum" class="form-control">
                    <option value="">&nbsp;</option>
                    @foreach (var item in ViewBag.orderList)
                    {
                        <option value="@Html.Raw("SL" + item.OrderNum.ToString("000"))">@item.ProductNO</option>
                    }
                </select>
                <input id="FOrderNumHidden" type="hidden" value="" />
                &nbsp;
            </div>
            <div class="btn-group" style="margin-top:-9px;">
                零件编号<br /><input id="txtNumber" name="txtNumber" type="text" class="form-control" /> &nbsp;
            </div>
            <div class="btn-group" style="margin-top:-9px;">
                零件名称<br /><input id="txtName" name="txtName" type="text" class="form-control input-width-185" /> &nbsp;
            </div>
            <div class="btn-group" style="margin-top:-9px;">
                装配路线<br /><input id="txtAssemble" name="txtAssemble" type="text" class="form-control input-width-40" /> &nbsp;
            </div>
            <div class="btn-group" style="margin-top:-9px;">
                制造路线<br /><input id="txtMake" name="txtMake" type="text" class="form-control" /> &nbsp;
            </div>
            <div class="btn-group" style="">
                <a id="btn_search" class="btn btn-primary center-block" onclick=""><span class="glyphicon glyphicon-search"></span> 检索</a>
            </div>
            <div class="btn-group" style="float:right;">
                <a id="" class="btn btn-primary center-block" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span> 刷新</a>
                <a id="" class="btn btn-primary center-block disabled" onclick=""><span class="glyphicon glyphicon-download"></span> 导出</a>
            </div>
        </div>
    </form>
    <div style="">
        <table id="gridList"></table>
        <div id="gridPager"></div>
    </div>
</div>

